package com.css.openapi.service.impl;


import com.css.common.core.constant.Result;

import com.css.openapi.BO.ShbdbhReq;
import com.css.openapi.BO.ShzhtxReq;
import com.css.openapi.feign.ZfjkpPtCommonClient;
import com.css.openapi.service.ApiGlService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import java.util.Map;
import java.util.Objects;

/**
 * @description:管理api服务实现类
 */
@Slf4j
@Service
public class ApiGlServiceImpl implements ApiGlService {
    @Resource
    private ZfjkpPtCommonClient zfjkpPtCommonClient;

    @Override
    public Result<Map<String, Object>> queryYe(ShbdbhReq req) {
        Map<String,Object> map =  zfjkpPtCommonClient.queryYe(req);
        final Integer code = (Integer) map.get("code");
        final String msg = (String) map.get("msg");

        if(0!=code) return Result.error(code,msg);
        //调用开放平台
        map.remove("code");
        map.remove("msg");
        return Result.ok(map);
    }

    @Override
    public Result<Map<String, Object>> withdrawals(ShzhtxReq req) {
        Map<String,Object> map =  zfjkpPtCommonClient.withDrawals(req);
        final Integer code = (Integer) map.get("code");
        final String msg = (String) map.get("msg");

        if(0!=code) return Result.error(code,msg);
        //调用开放平台
        map.remove("code");
        map.remove("msg");
        return Result.ok(map);
    }
}
